import 'dart:ffi';

void main(){
  print("Hello Dart");

  //数字类型
  num a = -1.0;//num是数字类型的父类型，子类可以是int和double
  num b = 100;
  num c = 0.2312;

  int num1 = 10;
  double num2 = 3.14;

  print(a.abs());//绝对值
  print(a.toInt());//转为int
  print(a.toDouble());


  //字符串类型
  String s1 = '单引号';
  String s2 = "双引号";
  print("字符串1：$s1,字符串2：$s2");
  print(s1.substring(0,2));
  print(s1.startsWith("aaa"));
  print(s1.replaceAll("单", "replace"));//替换“单”为“replace”
  print(s1.contains("other"));
  print(s1.split("引"));


  //布尔类型
  bool flag = true, flag2 = false;

  //List集合
  List list = [1,2,3,"集合"]; //初始化时，可以不指定类型，添加元素
  print(list);

  List<int> list2 = [1,2,3];
  
  List list3 = [];
  list3.add("value");
  list3.addAll(list2);

  List list4 = List.generate(3, (index) => index*2);//生成指定长度的list,这里是[0,2,4]
  print(list3);
  print(list4);

  for (var value in list4) {
    print(value);
  }


  //Map集合
  Map map = {"key1":1,"key2":"value2"};
  print(map);
  map.forEach((key,value){
    print("key:$key,value:$value");
  });

  Map<int,String> map2 = {1:""};

}